export const shortcuts = [
	{
		text: "近一周",
		value: () => {
			const end = new Date();
			const start = new Date();
			start.setTime(start.getTime() - 3600 * 1000 * 24 * 6);
			return [start, end];
		}
	},
	{
		text: "当日",
		value: () => {
			const end = new Date();
			const start = new Date();
			start.setTime(start.getTime());
			return [start, end];
		}
	},
	{
		text: "近30天",
		value: () => {
			const end = new Date();
			const start = new Date();
			start.setTime(start.getTime() - 3600 * 1000 * 24 * 29);
			return [start, end];
		}
	}
];
// 时间选择器范围禁用-30天
let start_time = 0;
export const calendarChange = ([start]: [Date, Date]) => {
	start_time = start.getTime();
};
const time_scope = 3600 * 1000 * 24 * 30;
export const disabledData = (time: any) => {
	const is_disable = start_time ? time.getTime() < start_time - time_scope || time.getTime() > start_time + time_scope : false;
	return time.getTime() > Date.now() || is_disable;
};

/**
 * @description 获取时间
 * @param {Number} data 时间戳
 * @example '2022-01-01'
 * */
export function getTime(data: number) {
	let date = new Date(data);
	let yyyy = date.getFullYear();
	let mm = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
	let dd = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
	return `${yyyy}-${mm}-${dd}`;
}
